﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using RooHui.Infrastructure.Entities.Entity;
using RooHui.OA.Biz;
using RooHui.Tool;
using System.IO;
using System.Drawing;

namespace RooHui.Admin.Web.Controllers
{
    public class InformationController : Controller
    {
        //
        // GET: /Information/
        public ActionResult Index()
        {
            return View();
        }

        
        /// <summary>
        /// 分页获取资迅信息
        /// </summary>
        /// <param name="page"></param>
        /// <param name="pageSize"></param>
        /// <param name="infoType"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult GetInfoListByPage(int page, int pageSize, int infoType, int status)
        {
            int count = 0;
            var infoList = InformationBiz.GetInfoListByPage(page, pageSize, infoType, status, ref count); 
            Dictionary<string, object> dic = new Dictionary<string, object>();
            dic.Add("Rows", infoList);
            dic.Add("Total", count);
            return Content(dic.ToJson());
        }

        public ActionResult InfoAdd()
        {
            return View();
        }

        /// <summary>
        /// 增加资迅
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpPost]
        public static bool InfoAdd(Information info)
        {
            bool bAddFlag = InformationBiz.InformationAdd(info);
            return bAddFlag;
        }

        public ActionResult InfoEdit()
        {
            return View();
        }

        /// <summary>
        /// 修改资迅
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpPost]
        public static bool InfoEdit(Information info)
        {
            bool bEditFlag = InformationBiz.InformationEdit(info.ID, info);
            return bEditFlag;
        }

        /// <summary>
        /// 修改资迅状态
        /// </summary>
        /// <param name="id"></param>
        /// <param name="destinationStatus"></param>
        /// <returns></returns>
        [HttpPost]
        public bool InfoStatusChange(int id, int destinationStatus)
        {
            bool bChangeFlag = InformationBiz.InfoStatusChange(id, destinationStatus);
            return bChangeFlag;
        }
    }
}
